package com.vf.admin.miaodong.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.SsCities;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * 市
 */
@Repository
public class AfterSsCitiesDao extends BaseDao<SsCities>{

    /**
     * 查询列表
     */
    public List<SsCities> list(Map<String,Object> paraMap, SplitPageBean splitPage) {
        ArrayList<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from ss_cities where 1=1  ");
        sbStr.append(" ORDER BY id ASC ");
        String sql = sbStr.toString();
        return this.queryList(sql,paramList, SsCities.class,splitPage);
    }

    /**
     * 详情
     */
    public SsCities get(Integer id) {
        if (id==null || id<=0) {
            return null;
        }
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from ss_cities where  id = ? ");
        paramList.add(id);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, SsCities.class);
    }


    /**
     * 添加/修改
     */
    public void save(SsCities ssCities) {
        if (ssCities!=null && ssCities.getId() != null && ssCities.getId() > 0) {
            this.update(ssCities);
        } else {
            ssCities.setId(this.add(ssCities));
        }
    }

    /**
     * 删除
     */
    public void del(Integer id) {
        if (id==null || id <= 0) {
            return;
        }
        String sql = "delete  from ss_cities where id = ?";
        ArrayList<Object> paramList = new ArrayList<Object>();
        paramList.add(id);
        this.del(sql, paramList);
    }

}
